home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: razine@aol.com (Razine)
- Newsgroups: comp.lang.c
- Subject: Calling a Function Twice from a printf statement.
- Date: 4 Mar 1996 02:40:57 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4he6q9$6r6@newsbf02.news.aol.com>
- Reply-To: razine@aol.com (Razine)
- NNTP-Posting-Host: newsbf02.mail.aol.com
-
- I am trying to call a function twice from my program on the same printf
- line and have run into a small problem. i was wondering if someone can
- explain how to fix it.
-
-
- void main(void) {
-
- printf("First Number is %d , the Second s %d \n",num(0),num(1));
-
- }
-
- int num(int index) {
- int return_number;
-
- switch(index) {
- case 0 : return_number=0;
- case 1 : return_number=1;
- }
- return(return_number);
- }
-
-
- Now with this function, the printf line will display 0 for the first one
- and garbage for the second one.. I then thought if I made the variable
- return_number a static variable it would have fixed it but then when i
- made the change the printf line would give me zero for both of them. Any
- ideas?
-
- Darrell
-
-